<div class="layui-row">
    <form class="layui-form">
        <div class="layui-inline">
            <label class="layui-form-label w-auto">短剧id：</label>
            <div class="layui-input-inline">
                <input type="text" name="video_id" placeholder="请输入短剧id" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label w-auto">短剧名称：</label>
            <div class="layui-input-inline">
                <input type="text" name="name" placeholder="请输入短剧名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <button class="layui-btn" style="margin-left: 10px;" lay-submit lay-filter="searchAuditRecord">搜索</button>
    </form>
</div>
<table id="third-audit-list" lay-filter="third-audit-list"></table>

<script type="text/html" id="audit-tbBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">详情</a>
</script>

<script>
    function getAuditTxt(d) {
        if (d.platform === 2) {
            if (d.audit_status) {
                return d.audit_status === 2 ? '可播放' : '不可播放';
            }
            return '审核中';
        }
        return '';
    }

    let params2 = {
        elem: '#third-audit-list'
        , url: '/admin/thirdAuditRecord/list' //数据接口
        , toolbar: ''
        , id: 'third-audit-list'
        , page:true
        , limit: 15
        , cols: [[ //表头
            { field: 'id', title: 'ID', width: 100, sort: true, align:'center' }
            , { field: 'video_id', title: '短剧ID', align:'center'}
            , { field: 'name', title: '短剧名称', align:'center'}
            , { field: 'cover_img', title: '封面图片', width: 180, align: 'center',
                templet: function (d) {
                    if (d.cover_img) {
                        return `<div class="layer-photos"  style="cursor:pointer;height: 100%;">
                                    <img onclick="showimg(this)" style="height: 100%;" src=`+ d.cover_img + ` alt="">
                                </div>`;
                    } else {
                        return `<div>暂无照片</div>`
                    }
                }
            }
            , { field: 'platform', title: '审核平台', align:'center',
                templet: function (d) {
                    return d.platform === 2 ? '抖音' : '';
                }
            }
            , { field: 'audit_status', title: '审核状态',align:'center',
                templet: function (d) {
                    return getAuditTxt(d)
                }
            }
            , { field: 'version', title: '版本号',align:'center'}
            , { field: 'scope_list', title: '能力列表',align:'center'}
            , { field: 'audit_remark', title: '审核备注', align:'center'}
            , { field: 'audit_at', title: '审核时间', align:'center'}
            , { toolbar: '#audit-tbBar', title: '操作', align:'center', width:270}
        ]]
    }

    tableList(params2)

    layui.use('table', function () {
        var table = layui.table;
        let form = layui.form;
        table.on('tool(third-audit-list)', function (obj) {
            var event = obj.event;
            if (event === 'detail') {
                x_admin_show(
                    `审核详情（短剧id:${obj.data.video_id} 短剧名称:${obj.data.name}）`,
                    `/admin/thirdAuditRecord/detail.html?id=${obj.data.id}&video_name=${obj.data.name}&platform=${obj.data.platform}`,
                    1150,
                    650,
                    null
                );
            }
        });
        form.on('submit(searchAuditRecord)', function (data) {
            params2.where = data.field
            tableList(params2)
            return false
        })
    });
</script>
